<template>
    <div class="user_module">
        <van-cell-group>
            <van-cell icon="star-o" title="收藏列表" to="/user/collect" isLink/>
            <van-cell icon="location-o" title="收货地址" to="/user/address" isLink/>
            <van-cell icon="phone-o" title="服务中心" to="/user/server" isLink/>
            <van-cell icon="orders-o" title="我的推广码" @click="pop" isLink/>
            <van-cell icon="credit-pay" title="我的银行卡" @click="bankcard" isLink/>
            <van-cell icon="todo-list-o" title="我的足迹" to="/user/foodPrint" isLink/>
            <van-cell icon="balance-o" title="推广" to="/bean" isLink/>
            <van-cell title="绑定手机" :value="mobile" icon="phone-circle-o" @click="BindMobile" disabled/>
            <van-cell title="绑定微信" :value="nickName" icon="wechat" @click="BindWx"/>

            <!-- 弹出绑定手机号组件 -->
            <bindmobile ref="dialogShow"/>


        </van-cell-group>
    </div>
</template>

<script>
    import Erweima from '@/views/user/erweima';
    import ewm from '@/views/user/ewm';
    import computeimg from '@/views/user/computeimg';
    import addbank from '@/views/user/bank/addbank';
    import banklist from '@/views/user/bank/banklist';
    import {Dialog} from 'vant';
    import {authLogout} from '@/api/api';
    import {removeLocalStorage} from '@/utils/local-storage';
    import bindmobile from "@/views/user/bindmobile";
    import {getLocalStorage, setLocalStorage} from "@/utils/local-storage";

    export default {
        name: 'user-module',
        components: {
            ewm: ewm,
            Erweima: Erweima,
            computeimg: computeimg,
            Dialog,
            bindmobile:bindmobile
        },
        data() {
            return {
                show: false,
                mobile: '',
                nickName: '',
                dialogShow: false,
                isclick: true,
                isPhoneClick:true
            }
        },
        created() {
            const {mobile} = getLocalStorage('mobile');
            const {nickName} = getLocalStorage('nickName');
            if (mobile) {
                this.mobile = mobile
                this.isPhoneClick = false
            } else {
                this.mobile = '未绑定手机号';
                this.isPhoneClick = true
            }
            if (nickName) {
                this.nickName = nickName
                this.isclick = false
            } else {
                this.nickName = '未绑定微信';
                this.isclick = true
            }
        },
        methods: {
            pop() {
                this.show = !this.show
                this.$router.push({name: 'user-promotion'})
                // this.$router.push({name:'user-computeimg'})
            },
            bankcard() {
                this.$router.push({name: 'user-banklist'})
            },
            BindMobile() {
                if (this.isPhoneClick) {
                    this.dialogShow = true
                    this.$refs.dialogShow.parentHandleclick(true);
                }
            },
            BindWx() {
                if (this.isclick) {
                    location.href = 'https://open.weixin.qq.com/connect/oauth2/authorize?appid=wx5b93f2b90f92962d&redirect_uri=' +
                        encodeURIComponent('http://www.moteer.top/#/loginbywx') + '&response_type=code&scope=snsapi_userinfo#wechat_redirect'
                }
            }
        }
    };
</script>


<style scoped lang="scss">
    .van-dialog {
        border-radius: 0;
        /*height: 557px*/
    }

    .user_module {
        background-color: #fff;
    }
</style>
